GtkAppChooser: Deal with 'no app found' gracefully
authorMatthias Clasen <mclasen@redhat.com>
Mon, 29 Aug 2011 02:43:20 +0000 (22:43 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 29 Aug 2011 02:46:46 +0000 (22:46 -0400)
Several functions inside GtkAppChooserDialog were not handling
the situation that app_info might be NULL after the user clicked
'Select'.

https://bugzilla.gnome.org/show_bug.cgi?id=651827

gtk/gtkappchooserdialog.c

index 5f0de03766f8d5cf48cd4ba7de3b3281b05dbe1b..178d291e20fbbca4f34fa645e2de28c89455fabb 100644 (file)
@@ -212,6 +212,12 @@ check_application (GtkAppChooserDialog  *self,
   command = NULL;
 
   info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->priv->app_chooser_widget));
+  if (info == NULL)
+    {
+      *app_out = NULL;
+      return FALSE;
+    }
+
   command = g_app_info_get_executable (info);
 
   g_shell_parse_argv (command, &argc, &argv, &error);
@@ -258,13 +264,15 @@ add_or_find_application (GtkAppChooserDialog *self)
 
   app = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self));
 
-  /* we don't care about reporting errors here */
-  if (self->priv->content_type)
-    g_app_info_set_as_last_used_for_type (app,
-                                         self->priv->content_type,
-                                         NULL);
-
-  g_object_unref (app);
+  if (app)
+    {
+      /* we don't care about reporting errors here */
+      if (self->priv->content_type)
+        g_app_info_set_as_last_used_for_type (app,
+                                              self->priv->content_type,
+                                              NULL);
+      g_object_unref (app);
+    }
 }
 
 static void